package com.treasure.service.collocate.controller;

import com.treasure.service.annotation.LogInfo;
import com.treasure.service.third.utils.SmsUtils;
import com.treasure.service.result.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
* @Description:    短信发送
* @Author:         panxinwen
* @CreateDate:     2018/11/18 18:31
* @Version:        1.0
*/
@Api(value = "短信发送",description = "发送短信验证码")
@RestController
@RequestMapping("/sms/v1")
public class SmsController {

    @Autowired
    private SmsUtils smsUtils;

    @ApiOperation(value = "获取banner列表", notes = "获取banner列表")
    @PostMapping("/sendSms")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "phonenumber", value = "手机号", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "type", value = "短信类型(1-注册 2-登录 3-修改手机号 4-完善个人信息)", required = true, dataType = "int", paramType = "query"),
    })
    @LogInfo(log = "获取banner列表",isPrint = true)
    public ResponseEntity sendSms(@RequestParam(value = "phonenumber",required = false) String phonenumber,
                                  @RequestParam(value = "type") Integer type
    ){

        ResponseResult result = smsUtils.sendSms(phonenumber,type);

        return ResponseEntity.ok(result);

    }

}
